🎖️GitЯра🎖️
Node / meshtastic / Meshtastic-Android / files / core / ui / src / commonMain / kotlin / org / meshtastic / core / ui / component / PmAqiSeverity.kt
Displaying Raw • Download
core/ui/src/commonMain/kotlin/org/meshtastic/core/ui/component/PmAqiSeverity.kt 1fdc9214896723f4be94aaa5c1d8527d2d1b04fa (1fdc9214) Text, 4.27 KB
T8b949e/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tff7b72package T7ee787org.meshtastic.core.ui.component
Tff7b72import T7ee787androidx.compose.material3.MaterialTheme
Tff7b72import T7ee787androidx.compose.runtime.Composable
Tff7b72import T7ee787androidx.compose.runtime.Stable
Tff7b72import T7ee787androidx.compose.ui.graphics.Color
Tff7b72import T7ee787androidx.compose.ui.graphics.luminance
Tff7b72import T7ee787org.jetbrains.compose.resources.StringResource
Tff7b72import T7ee787org.meshtastic.core.resources.Res
Tff7b72import T7ee787org.meshtastic.core.resources.aqi_good
Tff7b72import T7ee787org.meshtastic.core.resources.aqi_hazardous
Tff7b72import T7ee787org.meshtastic.core.resources.aqi_moderate
Tff7b72import T7ee787org.meshtastic.core.resources.aqi_unhealthy
Tff7b72import T7ee787org.meshtastic.core.resources.aqi_unhealthy_sensitive
Tff7b72import T7ee787org.meshtastic.core.resources.aqi_very_unhealthy
Tff7b72import T7ee787org.meshtastic.core.ui.theme.AqiSeverityColors
T8b949e/**
* EPA AQI severity categories for PM2.5-derived AQI (0-500), per meshtastic/design#54. Mirrors [Co2Severity]'s
* ppm→severity pattern, keyed on AQI value instead.
*
* The category name is a string resource (not a hardcoded literal like [Co2Severity]'s) because it is rendered next to
* the AQI value everywhere the category is shown — the category must never be conveyed by [color] alone.
*/
Tf0883e@Stable
Tf0883e@SuppressTb4b4b4(Ta5d6ff"Ta5d6ffMagicNumberTa5d6ff"Tb4b4b4)
Tff7b72enum Tff7b72class T56d364PmAqiSeverityTb4b4b4(
Tf0883e@Stable Tff7b72val Te6edf3tonesTb4b4b4: Te6edf3AqiSeverityColorsTb4b4b4.Te6edf3TonesTb4b4b4,
Tf0883e@Stable Tff7b72val Te6edf3labelResTb4b4b4: Te6edf3StringResourceTb4b4b4,
Tff7b72val Te6edf3rangeTb4b4b4: Te6edf3IntRangeTb4b4b4,
Tb4b4b4) Tb4b4b4{
Te6edf3GOODTb4b4b4(Te6edf3AqiSeverityColorsTb4b4b4.Te6edf3GoodTb4b4b4, Te6edf3ResTb4b4b4.Te6edf3stringTb4b4b4.Te6edf3aqi_goodTb4b4b4, T79c0ff0.Tb4b4b4.T79c0ff5T79c0ff0Tb4b4b4)Tb4b4b4,
Te6edf3MODERATETb4b4b4(Te6edf3AqiSeverityColorsTb4b4b4.Te6edf3ModerateTb4b4b4, Te6edf3ResTb4b4b4.Te6edf3stringTb4b4b4.Te6edf3aqi_moderateTb4b4b4, T79c0ff5T79c0ff1.Tb4b4b4.T79c0ff1T79c0ff0T79c0ff0Tb4b4b4)Tb4b4b4,
Te6edf3UNHEALTHY_SENSITIVETb4b4b4(Te6edf3AqiSeverityColorsTb4b4b4.Te6edf3UnhealthySensitiveTb4b4b4, Te6edf3ResTb4b4b4.Te6edf3stringTb4b4b4.Te6edf3aqi_unhealthy_sensitiveTb4b4b4, T79c0ff1T79c0ff0T79c0ff1.Tb4b4b4.T79c0ff1T79c0ff5T79c0ff0Tb4b4b4)Tb4b4b4,
Te6edf3UNHEALTHYTb4b4b4(Te6edf3AqiSeverityColorsTb4b4b4.Te6edf3UnhealthyTb4b4b4, Te6edf3ResTb4b4b4.Te6edf3stringTb4b4b4.Te6edf3aqi_unhealthyTb4b4b4, T79c0ff1T79c0ff5T79c0ff1.Tb4b4b4.T79c0ff2T79c0ff0T79c0ff0Tb4b4b4)Tb4b4b4,
Te6edf3VERY_UNHEALTHYTb4b4b4(Te6edf3AqiSeverityColorsTb4b4b4.Te6edf3VeryUnhealthyTb4b4b4, Te6edf3ResTb4b4b4.Te6edf3stringTb4b4b4.Te6edf3aqi_very_unhealthyTb4b4b4, T79c0ff2T79c0ff0T79c0ff1.Tb4b4b4.T79c0ff3T79c0ff0T79c0ff0Tb4b4b4)Tb4b4b4,
T8b949e/**
* EPA ends the scale at 500; the range saturates instead of stopping there so an out-of-scale value still reads as
* the worst category rather than losing its label. `aqiFromPm25` already clamps to 500, so this is defensive only.
*/
Te6edf3HAZARDOUSTb4b4b4(Te6edf3AqiSeverityColorsTb4b4b4.Te6edf3HazardousTb4b4b4, Te6edf3ResTb4b4b4.Te6edf3stringTb4b4b4.Te6edf3aqi_hazardousTb4b4b4, T79c0ff3T79c0ff0T79c0ff1.Tb4b4b4.Te6edf3IntTb4b4b4.Te6edf3MAX_VALUETb4b4b4)Tb4b4b4,
Tb4b4b4;
T8b949e/** The category color for [darkTheme], legible as body text on `surface` and `surfaceVariant` in both. */
Tff7b72fun Td2a8ffcolorForTb4b4b4(Te6edf3darkThemeTb4b4b4: Tffa657BooleanTb4b4b4)Tb4b4b4: Te6edf3Color Tff7b72= Tff7b72if Tb4b4b4(Te6edf3darkThemeTb4b4b4) Te6edf3tonesTb4b4b4.Te6edf3dark Tff7b72else Te6edf3tonesTb4b4b4.Te6edf3light
T8b949e/**
* The category color for the *applied* theme. Resolved from the surface actually in use rather than
* `isSystemInDarkTheme()`, so a user who forces light while the system is dark (or vice versa — `AppTheme` takes an
* explicit `darkTheme`) still gets the tone that was contrast-checked against the surface they are looking at.
*/
Tf0883e@Composable Tff7b72fun Td2a8ffcolorTb4b4b4(Tb4b4b4)Tb4b4b4: Te6edf3Color Tff7b72= Te6edf3colorForTb4b4b4(Te6edf3MaterialThemeTb4b4b4.Te6edf3colorSchemeTb4b4b4.Te6edf3surfaceTb4b4b4.Te6edf3luminanceTb4b4b4(Tb4b4b4) Tff7b72< Te6edf3DARK_SURFACE_LUMINANCETb4b4b4)
Tff7b72companion Tff7b72object Tb4b4b4{
T8b949e/**
* Midpoint luminance separating a light surface from a dark one. Well clear of both static schemes and of any
* plausible dynamic-color surface, which stay near the extremes.
*/
Tff7b72private Tff7b72const Tff7b72val Te6edf3DARK_SURFACE_LUMINANCE Tff7b72= T79c0ff0.5f
T8b949e/** Returns the [PmAqiSeverity] for the given 0-500 EPA [aqi] value, or null if negative. */
Tff7b72fun Td2a8fffromAqiTb4b4b4(Te6edf3aqiTb4b4b4: Tffa657IntTb4b4b4)Tb4b4b4: Te6edf3PmAqiSeverity? Tff7b72= Tff7b72when Tb4b4b4{
Te6edf3aqi Tff7b72< T79c0ff0 Tff7b72-Tff7b72> Tff7b72null
Te6edf3aqi Tff7b72<Tff7b72= Te6edf3GOODTb4b4b4.Te6edf3rangeTb4b4b4.Te6edf3last Tff7b72-Tff7b72> Te6edf3GOOD
Te6edf3aqi Tff7b72<Tff7b72= Te6edf3MODERATETb4b4b4.Te6edf3rangeTb4b4b4.Te6edf3last Tff7b72-Tff7b72> Te6edf3MODERATE
Te6edf3aqi Tff7b72<Tff7b72= Te6edf3UNHEALTHY_SENSITIVETb4b4b4.Te6edf3rangeTb4b4b4.Te6edf3last Tff7b72-Tff7b72> Te6edf3UNHEALTHY_SENSITIVE
Te6edf3aqi Tff7b72<Tff7b72= Te6edf3UNHEALTHYTb4b4b4.Te6edf3rangeTb4b4b4.Te6edf3last Tff7b72-Tff7b72> Te6edf3UNHEALTHY
Te6edf3aqi Tff7b72<Tff7b72= Te6edf3VERY_UNHEALTHYTb4b4b4.Te6edf3rangeTb4b4b4.Te6edf3last Tff7b72-Tff7b72> Te6edf3VERY_UNHEALTHY
Tff7b72else Tff7b72-Tff7b72> Te6edf3HAZARDOUS
Tb4b4b4}
Tb4b4b4}
Tb4b4b4}
Served by rngit 1.5.0 - Generated in 0.05s